/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - core/memory
// Copyright( c) 2013.  All Rights Reserved
//
// File:		AESystemObjectI.h
// Author:		Gianluca Belardelli
// Date:		09/04/2014
//
/////////////////////////////////////////////////////////////////////////
#ifndef _AESYSTEMOBJECT_H_
#define _AESYSTEMOBJECT_H_

class AESystemObjectI : public AESubjectI, public AEObserverI
{
	friend class AEEngineSystem;
	friend class AESystemSceneI;

// Members
protected:
	AEBOOL32		m_bInitialized;
    AEHANDLE		m_hParentObject;
    AESystemSceneI	*m_lpSystemScene;
	char			*m_lpName;

public:
    /// <summary>
    ///   Constructor.
    /// </summary>
    /// <remarks>
    ///   Inlined for performance.
    /// </remarks>
    /// <param name="pSystemScene">The scene this object belongs to.</param>
    /// <param name="pszName">Name of this GUI object.</param>
    AESystemObjectI( AESystemSceneI *lpSystemScene, char *lpName )
        : m_bInitialized( 0 ),
		m_lpSystemScene( lpSystemScene ),
		m_lpName( 0L )
    {
		if( lpName )
			SetName( lpName );
    }

    /// <summary>
    ///   Gets the system scene this object belongs to.
    /// </summary>
    /// <returns>A pointer to the system.</returns>
    AESystemSceneI *GetSystemScene( void ) { return m_lpSystemScene; }

    /// <summary>
    ///   Returns a handle to the parent object that this system object belongs to.
    /// </summary>
    /// <returns>A handle to the parent object.</returns>
    AEHANDLE GetParentObject( void ) { return m_hParentObject; }

    /// <summary>
    ///   Set a handle to the parent object that this system object belongs to.
    /// </summary>
    /// <remarks>This should only be called by the parent object.</remarks>
    /// <returns>A handle to the parent object.</returns>
    void SetParentObject( AEHANDLE hParentObject ) { m_hParentObject = hParentObject; }

    /// <summary>
    ///   Gets the system type for this system object.
    /// </summary>
    /// <remarks>
    ///   This is a shortcut to getting the system type w/o having to go the system first.
    /// </remarks>
    /// <returns>The type of the system.</returns>
    virtual AEUINT32 GetSystemType( void ) = 0;

	/// <summary>
    ///   Gets the name of the object.
    /// </summary>
    /// <returns>The name of the object.</returns>
    virtual AE_FORCEINLINE char *GetName( void ) { return m_lpName; }

	/// <summary>
    ///   Sets the name of the object.
    /// </summary>
    /// <param name="pszName">The new name of the object.</param>
    virtual AE_FORCEINLINE void SetName( char *lpName )
    {
		if( m_lpName )
			delete [] m_lpName;

		AEINT32 nLen = strlen( lpName );

		m_lpName = new char[ nLen + 1 ];
		strcpy( m_lpName, lpName );
    }

    /// <summary>
    ///   One time initialization function for the object.
    /// </summary>
    /// <param name="Properties">Property structure array to fill in.</param>
    /// <returns>An error code.</returns>
    //virtual AEUINT32 Initialize( std::vector<Properties::Property> Properties ) = 0;

    /// <summary>
    ///   Gets the properties of this object.
    /// </summary>
    /// <param name="Properties">The Property structure array to fill.</param>
    //virtual void GetProperties( std::vector<Properties::Property>& Properties ) = 0;

    /// <summary>
    ///   Sets the properties for this object.
    /// </summary>
    /// <param name="Properties">Property structure array to get values from.</param>
    //virtual void SetProperties( std::vector<Properties::Property> Properties ) = 0;

    /// <summary>
    ///   Returns a bit mask of System Changes that this system wants to receive changes for.  Used
    ///    to inform the change control manager if this system's object should be informed of the
    ///    change.
    /// </summary>
    /// <returns>A System::Changes::BitMask.</returns>
    virtual AEUINT32 GetDesiredSystemChangesMask( void ) = 0;
};

#endif // _AESYSTEMOBJECT_H_
